#pragma once

#include "BaseController.h"
#include "httplib.h"

class HttpServer
{
public:
    HttpServer(const std::string &hostname, uint16_t port);
    ~HttpServer();

private:
    void httpErrorHandler(const httplib::Request &req, httplib::Response &res);
    void httpExceptionHandler(const httplib::Request &req, httplib::Response &res, std::exception_ptr ep);

public:
    void addController(BaseController *controller);
    bool start();

private:
    std::string m_host;
    uint16_t    m_port;

    std::vector<BaseController *>    m_controllers;
    std::unique_ptr<httplib::Server> m_http_server;
};
